//
//  HttpEquipmentAction.m
//  EPBPro
//
//  Created by wucha on 2018/6/25.
//  Copyright © 2018年 fc. All rights reserved.
//

#import "HttpEquipmentAction.h"


@implementation HttpEquipmentAction
+(void)postEquipmentListWithAction:(NSDictionary*)dic block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionSearchEquipment parmasAndKeys:nil];
//    NSDictionary *dic = [Utils objectToDictionary:equipmentActionInfo];
    [self postRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getEquipmentListResultWithResponseData:) finish:block];
}

+(void)postAddEquipmentWithAction:(AddEquipmentActionInfo*)addContractActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionAddEquipment parmasAndKeys:nil];
    NSDictionary *dic = [Utils objectToDictionary:addContractActionInfo];
    [self postRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getAddEquipmentResultWithResponseData:) finish:block];
    
}

+(void)putModifyEquipmentWithAction:(AddEquipmentActionInfo*)addContractActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionModifyEquipment parmasAndKeys:nil];
    NSDictionary *dic = [Utils objectToDictionary:addContractActionInfo];
    [self putRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getModifyEquipmentResultWithResponseData:) finish:block];
    
}

+(void)getEquipmentInfoWithID:(NSString*)contractID block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:[NSString stringWithFormat:@"%@%@",ActionSearchEquipmentBYID,contractID] parmasAndKeys:nil];
    [self requestWithRequest:requestString jsonParserSelector:@selector(getEquipmentIDResultWithResponseData:) finish:block];
    
}

+(void)deleteEquipmentInfoWithID:(NSArray*)idArray block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:[NSString stringWithFormat:@"%@",ActionEquipmentDelete] parmasAndKeys:nil];
    NSDictionary *dic = @{@"equipmentIds":idArray};
    [self deleteRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getEquipmentDeleteResultWithResponseData:) finish:block];
    
}
#pragma mark-设备维护
+(void)postEquipmentRepairListWithAction:(EquipmentRepairActionInfo*)equipmentActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionSearchEquipmentRepair parmasAndKeys:nil];
    NSDictionary *dic = [Utils objectToDictionary:equipmentActionInfo];
    [self postRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getEquipmentRepairListResultWithResponseData:) finish:block];
}

+(void)postAddEquipmentRepairWithAction:(AddEquipmentRepairActionInfo*)addContractActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionAddEquipmentRepair parmasAndKeys:nil];
    NSDictionary *dic = [Utils objectToDictionary:addContractActionInfo];
    [self postRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getAddEquipmentRepairResultWithResponseData:) finish:block];
}

+(void)putModifyEquipmentRepairWithAction:(AddEquipmentRepairActionInfo*)addContractActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionModifyEquipmentRepair parmasAndKeys:nil];
    NSDictionary *dic = [Utils objectToDictionary:addContractActionInfo];
    [self putRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getModifyEquipmentRepairResultWithResponseData:) finish:block];
}

+(void)getEquipmentSimpleList:(EquipmentActionInfo*)equipmentActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionSearchEquipmentSimple parmasAndKeys:equipmentActionInfo.city,@"city",nil];
    requestString = [requestString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    [self requestWithRequest:requestString jsonParserSelector:@selector(getEquipmentSimpleListResultWithResponseData:) finish:block];
}

+(void)postAddEquipmentMaintain:(MaintainActionInfo*)maintainActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionSaveMaintain parmasAndKeys:nil];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setObject:maintainActionInfo.code forKey:@"code"];
    [params setObject:maintainActionInfo.descriptionOne forKey:@"description"];
    [params setObject:maintainActionInfo.location forKey:@"location"];
    [self postRequestWithRequest:requestString withParam:params jsonSelector:@selector(getAddEquipmentMaintaintResultWithResponseData:) finish:block];

}

+(void)putUpdateEquipmentMaintain:(MaintainActionInfo*)maintainActionInfo block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionUpdateMaintain parmasAndKeys:nil];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setObject:maintainActionInfo.id forKey:@"id"];
    [params setObject:maintainActionInfo.descriptionOne forKey:@"maintainComment"];
    [params setObject:@"maintained" forKey:@"status"];
    [params setObject:[Utils dateToString:[NSDate date]] forKey:@"endDate"];
    [self putRequestWithRequest:requestString withParam:params jsonSelector:@selector(getAddEquipmentMaintaintResultWithResponseData:) finish:block];
    
}

+(void)postEquipmentRentHistory:(NSString*)equipmentId block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:ActionEquipmentRent parmasAndKeys:nil];
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:[NSNumber numberWithInt:[equipmentId intValue]] forKey:@"equipmentId"];
    [self postRequestWithRequest:requestString withParam:dic jsonSelector:@selector(getEquipmentRentResultWithResponseData:) finish:block];

}

+(void)getSingleEquipmentInfo:(NSString*)equipmentId block:(HTTPResultBlock)block{
    NSString *requestString = [Utils getUrlWithAction:[NSString stringWithFormat:@"%@%@",ActionSingleMDetail,equipmentId] parmasAndKeys:nil];
    [self requestWithRequest:requestString jsonParserSelector:@selector(getSingleEquipmentDetailResultWithResponseData:) finish:block];
}

@end
